package com.cn.wanxi.Result;

import com.cn.wanxi.entity.User;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
public class Result {
    private Integer code;
    private String msg;
    private Integer count;
    private Object data;

    private Result() {
    }

    /**
     * 查询出的数据
     *
     * @param data
     * @return
     */
    public static Result getInstance(Object data) {
        return getResultModel(0, "", 0, data);
    }

    /**
     * 影响的条数
     *
     * @param count
     * @return
     */
    public static Result getInstance(Integer count) {
        return getResultModel(0, "", count, null);
    }

    private static Result getResultModel(int code, String msg, int count, Object data) {
        return new Result(code, msg, count, data);
    }

    /**
     * 返回的字符
     *
     * @param msg
     * @return
     */
    public static Result getInstance(String msg) {
        return new Result(0, msg, 0, null);
    }
}
